<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>@yield('title')</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <script type="text/javascript" src="{{asset('manger/plugins/layui2.0/layui.js')}}"></script>
    <link rel="stylesheet" href="{{asset('manger/plugins/layui2.0/css/layui.css')}}" media="all" />
    <link rel="stylesheet" href="{{asset('manger/plugins/font-awesome/css/font-awesome.min.css')}}">
    <script src="{{asset('js/jquery.min.js')}}"></script>
</head>
<body>
<div style="margin: 15px;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>@yield('barName')</legend>
    </fieldset>
    @yield('content')
</div>
<script>
    //得到时间
    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
        return currentdate;
    }
    //
        layui.use(['layer','form','layedit','laydate','jquery','upload'], function(){
        var layer = layui.layer;
        var form=layui.form;
        var laydate=layui.laydate;
        var layedit=layui.layedit;
        var $=layui.jquery;
        var upload=layui.upload;
        form.on('submit(form)',function(data){

        });
        form.on('radio(radio)', function(data){
                console.log(data.elem); //得到radio原始DOM对象
                console.log(data.value); //被点击的radio的value值
                 var radio=data.value;
                 if(radio==1){

                     $('#category_0').hide();
                     $('#category_1').show();

                 }else{
                     $('#category_1').hide();
                     $('#category_0').show();
                 }
            });


            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
        //创建编辑器
            layedit.set({
                uploadImage: {
                    url: '/admin/image/upload1' //接口url
                    ,type: 'post' //默认post

                }
            });
        var editIndex=layedit.build('editor',{
            hideTool:['face'],
        });
        var date=new Date();
        laydate.render({
            elem: '#test10'
            ,type: 'datetime'
            ,range: '~',
            min:getNowFormatDate()

        });
            //指定允许上传的文件类型
            upload.render({
                elem: '#test3'
                ,url: '/admin/image/upload1'
                ,accept: 'video' //普通文件
                ,before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                    layer.load(); //上传loading
                }
                ,done: function(res, index, upload){
                    layer.closeAll('loading'); //关闭loading

                    layer.msg('上传成功');

                    $("#video").val(res.data.src);
                    $("#source").attr('src','/storage/'+res.data.src);
                    $("#my_video").show();
                }
                ,error: function(index, upload){
                    layer.closeAll('loading'); //关闭loading
                }
            });
        //日期
        //验证错误
        @if (count($errors) > 0)

            @foreach ($errors->all() as $error)
            layer.msg('{{$error}}', {icon: 5},function () {

            });
            @endforeach
        @endif
        //返回成功信息
        @if(session('info'))
            @if(session('info')=='success')
               layer.msg('{{session('msg')}}',{icon:1});
        @else
              layer.msg('{{session('msg')}}',{icon:5});
                @endif
         @endif
    })
</script>
</body>

</html>